/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.smg.community.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.smg.community.model.*;
import com.smg.community.dao.*;
import com.smg.community.service.*;
import com.smg.community.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import org.springframework.stereotype.Repository;


@Repository
public class SmgMemberDao extends BaseIbatis3Dao<SmgMember,java.lang.Integer>{
	
	@Override
	public String getIbatisMapperNamesapce() {
		return "SmgMember";
	}
	
	public void saveOrUpdate(SmgMember entity) {
		if(entity.getMemberId() == null) 
			save(entity);
		else 
			update(entity);
	}
	
	public Page findPage(SmgMemberQuery query) {
		return pageQuery("SmgMember.findPage",query);
	}

	public SmgMember getByLoginNameAndPassword(String loginName, String password) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("password",password);
		map.put("loginName",loginName);
		return (SmgMember)this.getSqlSessionTemplate().selectOne("SmgMember.getByLoginNameAndPassword", map);
	}

	public List<SmgMember> getNerybyMember(Float gpsLatitude,
			Float gpsLongitude, int scope, int pageNumber,String sex,String memberCarType,String memberId) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("gpsLatitude",gpsLatitude);
		map.put("gpsLongitude",gpsLongitude);
		map.put("scope", scope);
		map.put("start",(pageNumber-1)*20);
		map.put("limit", 20);
		map.put("sex",sex);
		map.put("memberCarType",memberCarType);
		map.put("memberId",memberId);
		return this.getSqlSessionTemplate().selectList("SmgMember.getNerybyMember", map);
	}

	public List<SmgMember> getListByMobileNumbers(String mobileNumbers) {
		return this.getSqlSessionTemplate().selectList("SmgMember.getListByMobileNumbers", mobileNumbers);
	}

	public SmgMember getByLoginName(String loginName) {
		return  (SmgMember)this.getSqlSessionTemplate().selectOne("SmgMember.getByLoginName", loginName);
	}

	public List<SmgMember> getFriendMemberListByMemberId(String memberId, int start, int limit) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("memberId",memberId);
		map.put("start",start);
		map.put("limit", limit);
		return this.getSqlSessionTemplate().selectList("SmgMember.getFriendMemberListByMemberId", map);
	}

	public SmgMember getByNickname(String nickName) {
		return  (SmgMember)this.getSqlSessionTemplate().selectOne("SmgMember.getByNickname", nickName);
	}

	public void updateuuid(Integer memberId, String uuid) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("memberId",memberId);
		map.put("uuid", uuid);
		 this.getSqlSessionTemplate().update("SmgMember.updateuuid", map);
	}

	public void updateNickname(Integer memberId, String nickName) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("memberId",memberId);
		map.put("nickName", nickName);
		 this.getSqlSessionTemplate().update("SmgMember.updateNickname", map);
	}

	public void updateNicknameFirstchar(Integer memberId,
			String nickNameFirstchar) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("memberId",memberId);
		map.put("nickNameFirstchar", nickNameFirstchar);
		 this.getSqlSessionTemplate().update("SmgMember.updateNicknameFirstchar", map);
	}

	public List<SmgMember> getMajiaList() {
		// TODO Auto-generated method stub
		return (List<SmgMember> )this.getSqlSessionTemplate().selectList("SmgMember.getMajiaList", null);
	}

	public List<SmgMember> getActivityMemberList() {
		return  (List<SmgMember> )this.getSqlSessionTemplate().selectList("SmgMember.getActivityMemberList", null);
	}
	

}
